package com.itheima.common.vo;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.io.Serializable;

//统一的返回
@Data
@AllArgsConstructor
public class Result implements Serializable {
    //代表后端的请求是成功 还是失败
    private boolean success;
    //后端返回的错误代码或者成功代码
    private Integer code;
    //后端返回的信息
    private String message;
    //后端返回的数据
    private Object data;

    public static Result success(Object data) {
        return new Result(true,200,"success",data);
    }

    public static Result fail(int code, String message) {
        return new Result(false,code,message,null);
    }

    public static Result fail() {
        return new Result(false,500,"系统错误",null);
    }
}
